//
//  ViewController.m
//  ZPPermanentThreadDemo
//
//  Created by mac on 2020/3/17.
//  Copyright © 2020 com.codezp. All rights reserved.
//

#import "ViewController.h"
#import "ZPPermanentThread.h"

@interface ViewController ()
/** 线程对象 */
@property (nonatomic, strong) ZPPermanentThread *thread;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 创建线程
    self.thread = [[ZPPermanentThread alloc] init];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    // 任务
    [self.thread executeTaskWithTarget:self action:@selector(test)];
    // 任务
    [self.thread executeTask:^{
        NSLog(@"block-----block-----block-----%@", [NSThread currentThread]);
    }];
}

- (void)test {
    NSLog(@"-----任务-----任务-----%@", [NSThread currentThread]);
}

- (IBAction)stop {
    // 停止
    [self.thread stop];
}

- (void)dealloc {
    NSLog(@"%s", __func__);
}

@end
